package com.javabase.study.PracticeQuestions;

/**
 * TODO
 * 内容：
 * 作者:jxx
 * 创建时间：2021/7/21
 */
public class Fbnica {
    public static void main(String[] args){
        System.out.println(fonica(1));
    }

    public static int fonica(int n){
        if(n == 1){
            return 1;
        }else if(n == 2){
            return 2;
        }else {
            int first = 1;
            int second = 2;
            int third = 0;
            for (int i = 3; i <= n; i++) {
                third = first + second;
                first = second;
                second = third;
            }
            return third;
        }
    }
}
